home *** CD-ROM | disk | FTP | other *** search
- Path: news.mindlink.net!news
- From: genew@mindlink.bc.ca (Gene Wirchenko)
- Newsgroups: comp.lang.c
- Subject: Re: HELP: What is wrong ?
- Date: Tue, 16 Jan 1996 10:49:22 GMT
- Organization: MIND LINK! - British Columbia, Canada
- Message-ID: <4dfvu2$q18@fountain.mindlink.net>
- References: <4df373$kd3@ns.etri.re.kr>
- NNTP-Posting-Host: line023.nwm.mindlink.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- jinsoo@etri.re.kr (Jin-Soo Lee) wrote:
-
- > Your KIND HELP is needed.
- > I have some problems in the following code.
-
- >---------
-
- >#define DSKPAGESIZE 16*1024
- >#define LOGBUFSIZE 2*DSKPAGESIZE
-
- >main()
- >{
- > int pageBS, logoffset, bufferoffset, buffersize, length;
- > int freespace, inusefile;
- > char *globla_page;
- > T_LOGRECORD *tlogrec;
- >....
- >(1) pageBS = (logoffset/LOGBUFSIZE) * LOGBUFSIZE;
- >....
- >(2) bufferoffset = (logoffset + length)%LOGBUFSIZE;
- >....
- >(3) tlogrec = (T_LOGRECORD *)(global_page + (logoffset%LOGBUFSIZE));
- >....
- > freespace = inuselogfile - logoffset;
- >(4) if (freespace - length > sizeof(int))
- >....
- > freespace = buffersize - bufferoffset;
- >(5) if (freespace - length >= sizeof(int))
- >....
- >}
-
- >---------
-
- > The code worked well on SUN OS 4.1.3. and K&R C with dbx,
- > but goes wrong when moved to current environment,
- > Solaris 2.4 and SUN C with SparcWorks dbx and gcc with gdb.
- > The statements (1) ~ (5) sometimes make too big or negative values.
-
- If negative, it could be overflow. Increase to long (assuming
- that's longer on your implementation).
-
- > I can't believe it.
-
- Would your computer lie to you? Don't you trust it? <G>
-
- > What happened ?
- > OS or compiler problem ? or C language syntax problem ?
-
- > Any help is greatly appreciated. Please e-mail me.
-
- >--
- >Jin-Soo Lee Internet: jinsoo@dbserver.etri.re.kr
- >DB Section, Electronics and Telecommunications Research Inst. (ETRI)
- >P.O. Box 106, You-Seong, Taejon, 305-600, Korea
- >TEL: +82-42-860-4865 FAX: +82-42-860-6645
-
- C Pronunciation Guide:
- y=x++; "wye equals ex plus plus semicolon"
- x=x++; "ex equals ex doublecross semicolon"
-
-